home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / System / XFD / Developer / Sources / ASM / PP2S.a < prev    next >
Encoding:
Text File  |  2001-09-16  |  3.7 KB  |  190 lines

  1. *******************************************************
  2. **             XFD external decruncher               **
  3. **      for PowerPacker (sample mode) cruncher       **
  4. **             adapted by Wanted Team                **
  5. *******************************************************
  6.  
  7.     INCLUDE    "AINCLUDE:IncDirs.i"
  8.     INCLUDE    "libraries/xfdmaster.i"
  9.  
  10. ; xfdForeman structure MUST be first thing in all external decrunchers
  11.  
  12. ForeMan        moveq    #-1,d0        ;security
  13.         rts
  14.         dc.l    XFDF_ID        ;id
  15.         dc.w    1        ;version
  16.         dc.w    0
  17.         dc.l    0,0        ;private
  18.         dc.l    S_PP2S        ;first slave
  19.  
  20. **************************************************
  21.  
  22. ; xfdSlave structure: this one doesn't support data scanning
  23.  
  24. S_PP2S        dc.l    0        ;no more slaves
  25.         dc.w    2        ;version
  26.         dc.w    39        ;master version
  27.         dc.l    N_PP2S        ;name
  28.         dc.w    XFDPFF_DATA!XFDPFF_RECOGLEN!XFDPFF_USERTARGET
  29.         dc.w    0
  30.         dc.l    RB_PP2S        ;recog buffer
  31.         dc.l    DB_PP2S        ;decrunch buffer
  32.         dc.l    0        ;recog segment
  33.         dc.l    0        ;decrunch segment
  34.         dc.w    0,0
  35.         dc.l    12+2
  36.  
  37.         dc.b    "$VER: PP2S 2.1 (09.06.2001) by Wanted Team",0
  38. N_PP2S        dc.b    "PowerPacker data cruncher (sample mode)",0
  39.         even
  40.  
  41. ;-------------------------------------------------
  42.  
  43. ; Recog buffer function: receives buffer + length in a0/d0
  44.  
  45. RB_PP2S
  46.     btst    #0,D0
  47.     bne.b    Exit
  48.     cmp.l    #"PP2S",(A0)+
  49.     bne.b    Exit
  50.     cmp.l    #$09090909,(A0)            ; Fast
  51.     beq.b    OK
  52.     cmp.l    #$090A0A0A,(A0)            ; Mediocre
  53.     beq.b    OK
  54.     cmp.l    #$090A0B0B,(A0)            ; Good
  55.     beq.b    OK
  56.     cmp.l    #$090A0C0C,(A0)            ; Very good
  57.     beq.b    OK
  58.     cmp.l    #$090A0C0D,(A0)            ; Best
  59.     bne.b    Exit
  60. OK
  61.     subq.l    #4,A0
  62.     add.l    D0,A0
  63.     moveq    #1,D5
  64.     move.l    D5,-(a7)
  65.     move.l    -(A0),D1
  66.     tst.b    D1
  67.     beq.b    Podziel
  68.     bsr.w    lbC0105BE
  69.     subq.b    #1,D1
  70.     lsr.l    D1,D5
  71. Podziel
  72.     lsr.l    #8,D1
  73.     move.l    D1,xfdrr_FinalTargetLen(A1)
  74.     move.l    D1,xfdrr_MinTargetLen(A1)
  75.     moveq    #1,D0
  76.     move.l    (A7)+,D5
  77.     rts    
  78. Exit
  79.     moveq    #0,D0
  80.     rts
  81.  
  82. ;-------------------------------------------------
  83.  
  84. ; Decrunch buffer function: receives bufferinfo in a0
  85. ; This style requires xfdmaster.library V39
  86. DB_PP2S    
  87.     movem.l    D2-D7/A2-A6,-(A7)
  88.     move.l    A0,A5
  89.     move.l    xfdbi_UserTargetBuf(A5),A1
  90.     move.l    xfdbi_SourceBuffer(A5),A0
  91.     move.l    xfdbi_SourceBufLen(A5),D0
  92.     lea    4(A0),A3
  93.     add.l    D0,A0
  94.     bsr.b    D_PP2S
  95.     moveq    #1,D0
  96.     movem.l    (A7)+,D2-D7/A2-A6
  97.     rts
  98.  
  99. ;-------------------------------------------------
  100.  
  101. ; Decruncher from EaglePlayer 1.54
  102.  
  103. ; Input
  104. ; A0 = Start + size of loaded file
  105. ; A1 = destination 
  106.  
  107. D_PP2S        BSR.B    lbC010586
  108.         move.l    xfdbi_UserTargetBuf(A5),A0
  109.         move.l    xfdbi_FinalTargetLen(A5),D0
  110.         SUBQ.L    #1,D0
  111.         MOVE.B    (A0)+,D1
  112. lbC010570    MOVE.B    (A0),D2
  113.         ADD.B    D1,D2
  114.         MOVE.B    D2,(A0)+
  115.         MOVE.B    D2,D1
  116.         SUBQ.L    #1,D0
  117.         BNE.S    lbC010570
  118.         RTS
  119. lbC010586    MOVEA.L    A1,A2
  120.         MOVEQ    #3,D6
  121.         MOVEQ    #7,D7
  122.         MOVEQ    #1,D5
  123.         MOVE.L    -(A0),D1
  124.         TST.B    D1
  125.         BEQ.S    lbC01059A
  126.         BSR.S    lbC0105BE
  127.         SUBQ.B    #1,D1
  128.         LSR.L    D1,D5
  129. lbC01059A    LSR.L    #8,D1
  130.         ADDA.L    D1,A2
  131. lbC01059E    BSR.S    lbC0105BE
  132.         BCS.S    lbC0105E0
  133.         MOVEQ    #0,D2
  134. lbC0105A4    MOVEQ    #1,D0
  135.         BSR.S    lbC0105CC
  136.         ADD.W    D1,D2
  137.         CMP.W    D6,D1
  138.         BEQ.S    lbC0105A4
  139. lbC0105AE    MOVEQ    #7,D0
  140.         BSR.S    lbC0105CC
  141.         MOVE.B    D1,-(A2)
  142.         DBRA    D2,lbC0105AE
  143.         CMPA.L    A2,A1
  144.         BCS.S    lbC0105E0
  145.         RTS
  146. lbC0105BE    LSR.L    #1,D5
  147.         BEQ.S    lbC0105C4
  148.         RTS
  149. lbC0105C4    MOVE.L    -(A0),D5
  150.         ROXR.L    #1,D5
  151.         RTS
  152. lbC0105CA    SUBQ.W    #1,D0
  153. lbC0105CC    MOVEQ    #0,D1
  154. lbC0105CE    LSR.L    #1,D5
  155.         BEQ.S    lbC0105DA
  156. lbC0105D2    ROXL.L    #1,D1
  157.         DBRA    D0,lbC0105CE
  158.         RTS
  159. lbC0105DA    MOVE.L    -(A0),D5
  160.         ROXR.L    #1,D5
  161.         BRA.S    lbC0105D2
  162. lbC0105E0    MOVEQ    #1,D0
  163.         BSR.S    lbC0105CC
  164.         MOVEQ    #0,D0
  165.         MOVE.B    0(A3,D1.W),D0
  166.         MOVE.W    D1,D2
  167.         CMP.W    D6,D2
  168.         BNE.S    lbC010606
  169.         BSR.S    lbC0105BE
  170.         BCS.S    lbC0105F6
  171.         MOVEQ    #7,D0
  172. lbC0105F6    BSR.S    lbC0105CA
  173.         MOVE.W    D1,D3
  174. lbC0105FA    MOVEQ    #2,D0
  175.         BSR.S    lbC0105CC
  176.         ADD.W    D1,D2
  177.         CMP.W    D7,D1
  178.         BEQ.S    lbC0105FA
  179.         BRA.S    lbC01060A
  180. lbC010606    BSR.S    lbC0105CA
  181.         MOVE.W    D1,D3
  182. lbC01060A    ADDQ.W    #1,D2
  183. lbC01060C    MOVE.B    0(A2,D3.W),-(A2)
  184.         DBRA    D2,lbC01060C
  185. lbC010620    CMPA.L    A2,A1
  186.         BCS.B    lbC01059E
  187.         RTS
  188.         
  189.         END
  190.